﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JLL.China.Infrastructure.Repositories.ProjectDirectoryMedia;
using JLL.China.Infrastructure.RepositoryFramework;

namespace JLL.China.Infrastructure.Repositories.Pages
{
   public class PagesRepository:SQLRepositoryBase<Model.Pages, int>, IPagesRepository
    {
       public override Model.Pages FindBy(int key)
       {
           throw new NotImplementedException();

       }
        public override IList<Model.Pages> FindAll()
        {
           
            var items = (from m in DataContext.Pages
                         where m.CheckSideContent.Equals(true)
                         select m);
            if (items != null)
            {
                var result = new List<Model.Pages>();
                var list = items.ToList();
                
                foreach (var obj in list)
                {
                    var listpage = DataContext.f_implode_listsidecontent(obj.Page_ID);
                    result.Add(new Model.Pages { ID = (int)obj.Page_ID, Name = obj.PageName, ListSideContent = listpage, CheckSideContent = obj.CheckSideContent });
                }
                return result;
            }
            return null;
        }

        protected override void PersistNewItem(Model.Pages item)
        {
            throw new NotImplementedException();
        }
        //

        //
        protected override void PersistUpdatedItem(Model.Pages item)
        {
            throw new NotImplementedException();
            
        }
        protected override void PersistDeletedItem(Model.Pages item)
        {
            throw new NotImplementedException();
        }
        public string FindById(int id)
        {
            var listbanner = DataContext.f_implode_listsidecontent(id);
            return listbanner;

        }

       public decimal UpdateListBanner(int id,string list)
       {
           return DataContext.sp_page_side_content(id,list);
       }
    }
}
